package com.ptu.mapper;

import com.github.pagehelper.Page;
import com.ptu.annotation.AutoFill;
import com.ptu.dto.CommentDTO;
import com.ptu.dto.CommentPageQueryDTO;
import com.ptu.dto.DishPageQueryDTO;
import com.ptu.entity.Comment;
import com.ptu.entity.Dish;
import com.ptu.enumeration.OperationType;
import com.ptu.vo.CommentVO;
import com.ptu.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {

    /**
     * 插入评论数据
     * @param comment
     */
    @Insert("insert into comment (content, score, image, store_id, users_id, order_id, comment_time, reply_time) " +
            "values (#{content}, #{score}, #{image}, #{storeId}, #{usersId}, #{orderId}, #{commentTime}, #{replyTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Comment comment);


    /**
     * 根据id查询评论
     * @param orderId
     * @return
     */
    @Select("select * from comment where order_id = #{orderId}")
    Comment getByOrderId(Long orderId);

    /**
     * 根据id查询评论
     * @param storeId
     * @return
     */
    @Select("select * from comment where store_id = #{storeId}")
    List<Comment> getByStoreId(Long storeId);

    Page<CommentVO> pageQuery(CommentPageQueryDTO commentPageQueryDTO);

    /**
     * 修改菜品
     * @param comment
     */
    void update(Comment comment);

    //
//    /**
//     * 根据id删除评论
//     * @param id
//     */
//    @Delete("delete from comment where id = #{id}")
//    void deleteById(Long id);
}